package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.hjq.shape.view.ShapeImageView;
import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.MeCertificateApi;
import com.jjb.www.http.glide.GlideApp;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class MeCertificateAdapter extends AppAdapter<MeCertificateApi.Bean> {

    public MeCertificateAdapter(Context context) {
        super(context);
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvPostName;
        private ShapeImageView mImgImg;
        private ShapeTextView mTvCertNum;
        private ShapeTextView mTvExpiryDate;



        private ViewHolder() {
            super(R.layout.item_certificate);
            mTvPostName = findViewById(R.id.tv_post_name);
            mImgImg = findViewById(R.id.img_img);
            mTvCertNum = findViewById(R.id.tv_cert_num);
            mTvExpiryDate = findViewById(R.id.tv_expiry_date);
        }

        @Override
        public void onBindView(int position) {
            MeCertificateApi.Bean bean  = getItem(position);
            mTvPostName.setText(bean.getPost_name());
            mTvCertNum.setText("证书编号："+bean.getCert_num());
            mTvExpiryDate.setText(bean.getExpiry_date());
            GlideApp.with(getContext())
                    .load(bean.getImg())
                    .into(mImgImg);
        }
    }
}